# Author    :Dun_Hz
# Time      :2024/3/15 16:31
# 实现归并排序
def mergesort(seq):
    mid = len(seq)//2
    if len(seq) <=1:
        return seq
    left = mergesort(seq[:mid])
    print('1:'+str(left))
    right = mergesort(seq[mid:])
    print('2:'+str(right))
    res = []
    print('3:'+str(res))
    while left and right:
        if left[-1] >= right[-1]:

            res.append(left.pop())
        else:
            res.append(right.pop())
    print('7'+str(left+right+res))
    res.reverse()
    return left+right+res

print(mergesort([1,6,12,3,7]))